#ifndef LED_PAINTER_H
#define LED_PAINTER_H

class DataManager;

typedef unsigned char byte;

// the encoding array for time number (0 ~ 9, :)
enum {
    LIB_NUM_0= 0,
    LIB_NUM_1,
    LIB_NUM_2,
    LIB_NUM_3,
    LIB_NUM_4,
    LIB_NUM_5,
    LIB_NUM_6,
    LIB_NUM_7,
    LIB_NUM_8,
    LIB_NUM_9,
    LIB_COLON,

    SYMBOL_COUNT
};
byte const timeNumLib16[SYMBOL_COUNT][16] = {
    {0x00,0x00,0x00,0x7C,0xEC,0xEE,0xEE,0xC6, 0xC6,0xC6,0xEE,0xEE,0xEC,0x7C,0x00,0x00},   // 0
    {0x00,0x00,0x00,0x18,0x38,0x78,0x78,0x18, 0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00},   // 1
    {0x00,0x00,0x00,0x7C,0xEE,0xE6,0x06,0x0E, 0x1C,0x1C,0x38,0x70,0xE0,0xFE,0x00,0x00},   // 2
    {0x00,0x00,0x00,0x7C,0xEC,0xEE,0x0E,0x0C, 0x3C,0x0E,0x06,0xEE,0xEE,0x7C,0x00,0x00},   // 3
    {0x00,0x00,0x00,0x1C,0x1C,0x3C,0x3C,0x7C, 0xFC,0xDC,0xFE,0x1C,0x1C,0x1C,0x00,0x00},   // 4
    {0x00,0x00,0x00,0x7E,0x60,0xE0,0xE0,0xFC, 0xEE,0x0E,0x06,0xEE,0xEE,0x7C,0x00,0x00},   // 5
    {0x00,0x00,0x00,0x7C,0x6E,0xEE,0xC0,0xFC, 0xEE,0xEE,0xC6,0xEE,0xEE,0x7C,0x00,0x00},   // 6
    {0x00,0x00,0x00,0xFE,0x0E,0x1C,0x1C,0x38, 0x38,0x30,0x70,0x70,0x70,0x70,0x00,0x00},   // 7
    {0x00,0x00,0x00,0x7C,0xEC,0xEE,0xEE,0xEE, 0x7C,0xEE,0xC6,0xC6,0xEE,0x7C,0x00,0x00},   // 8
    {0x00,0x00,0x00,0x7C,0xEC,0xEE,0xC6,0xEE, 0xEE,0x7E,0x06,0xEE,0xEC,0x7C,0x00,0x00},   // 9
    {0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00, 0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x00}    // :
};

// vector for graphics
class GraphVector {
public:
    byte x;
    byte y;
    GraphVector(){}
    GraphVector(byte initx, byte inity)
        : x(initx), y(inity)
    {}
};

class LedPainter
{
public:
    // define paint method.
    enum PaintMethod {
        PM_COPY = 0,    // paint using direct drawing method
        PM_XOR  = 1     // paint using not method
    };
    enum {
        SCRN_LENGTH = 64,
        SCRN_HEIGHT = 16
    };
private:
    // graphics memory pointer.
    DataManager *graphMem;
    
public:
    // must initial with graphics memory pointer.
    LedPainter(DataManager *);
    ~LedPainter();

    // clear the screen, make all led off.
    void ClearScreen();
    // draw point using method.
    void DrawPoint(GraphVector const, enum PaintMethod);
    void DrawPoint(int const, int const, enum PaintMethod);
    // using the paint method to draw a rect/line at top-left, button-right area.
    void DrawRect(GraphVector const, GraphVector const, enum PaintMethod);
    void DrawLine(GraphVector const, GraphVector const, enum PaintMethod);
    // draw a number place it's top-left conner on specific location.
    void DrawNumber(GraphVector const, byte const, enum PaintMethod method = PM_COPY);
    // draw a number(time) string on specific location (top-left).
    void DrawString(GraphVector const, byte const[], byte, enum PaintMethod method = PM_COPY);
    // draw a cursor on specific location using NOT method.
    void DrawCursor(GraphVector, byte size = 3, enum PaintMethod method = PM_XOR);
};

#endif // #ifndef ED_PAINTER_H

